package news

import (
	"gq_volunteer_platform/bean"
	"gq_volunteer_platform/model/news"

	"github.com/gin-gonic/gin"
)

func CategoryList(c *gin.Context) {

	var list []struct {
		ID   uint
		Name string
	}

	// 查询列表
	if err := bean.MysqlDb.Model(&news.NewsCategory{}).Where("`is_show`=?", "是").Order("sort ASC").Find(&list).Error; err != nil {
		bean.Log.Error(err)
		c.String(500, err.Error())
		return
	}

	c.PureJSON(200, gin.H{
		"list": list,
	})

}
